<?php
/*
	插件链接选择页面
*/
defined('BY_JYA') or exit('error');
//系统链接获取接口
$return=array();
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$tabs=array(
	array('op'=>'system','plugin'=>'core','action'=>'tools.link','title'=>'系统页面链接'),
	array('op'=>'list','title'=>'插件页面'),
	array('op'=>'schoollist','title'=>'机构列表'),
);
if($_RQ['op']=='list'){
	$return['list']=array(
		array('title'=>'首页','url'=>'jy_lvpai/index/'),
		array('title'=>'我的店铺','url'=>'jy_lvpai/myshop/'),
		array('title'=>'入驻','url'=>'jy_lvpai/manage.login/'),
	);
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>false,'delall'=>false,'del_one'=>false,'pagelist'=>false,'list'=>array(
			array('name'=>'title','title'=>'标题','type'=>'string'),
			array('name'=>'createtime','title'=>'创建时间','type'=>'string'),
		),'action'=>array(
			array('type'=>'modal_result','name'=>'url','title'=>'选取'),
		)),
		'search_one'=>array('name'=>'title','add'=>false),
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='schoollist'){
	$params=array();
	$params['uniacid']=$_SESSION['uniacid'];
	$params['status']='1';
	if(!empty($_RQ['title'])){
		$params['title like']='%'.trim($_RQ['title']).'%';
		$return['params']['title']=$_RQ['title'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$fields=array('id','mid','star','salecate','cateid','mobile','realname','status','jointime','accounttime','logo','title');
    $orderby='star desc, id desc';
	$list=pdo_getslice('jy_lvpai_jigou',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	foreach($list as &$v){
		$v['jointime']=date('Y/m/d H:i:s',$v['jointime']);
		$v['url']='jy_lvpai/myshop//id='.$v['id'];
		$v['member']=cfc('core')->member_show($v['mid']);
		$v['catename']=pdo_getcolumn('jy_lvpai_category',array('id'=>$v['cateid'],'uniacid'=>$_SESSION['uniacid']),'catename');
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>false,'delall'=>false,'del_one'=>false,'tip'=>'[<red>温馨提示</red>]:没有地址，经纬度的机构，在某些情况下（外卖，附近机构等）可能不会显示出来！','list'=>array(
			array('name'=>'id','title'=>'ID','type'=>'string'),
			array('title'=>'机构信息_Merch','type'=>'img_string','img'=>'logo',
			'data'=>array(
				array('title'=>'名称：','name'=>'title'),
				array('title'=>'项目：','name'=>'salecate')
				)
			),
			array('name'=>'member','title'=>'会员信息_Member','type'=>'member'),
			array('title'=>'联系人_Merch','type'=>'img_string',
			'data'=>array(
				array('title'=>'联系人：','name'=>'realname'),
				array('title'=>'电话：','name'=>'mobile')
				)
			),
			array('name'=>'catename','title'=>'所属分类','type'=>'string'),
			array('name'=>'status','title'=>'状态','type'=>'radio','options'=>'status2'),						
		),'action'=>array(
			array('type'=>'modal_result','name'=>'url','title'=>'选取'),
		)),
		'search_one'=>array('name'=>'title','add'=>false),
	);
	$return['status2']=array('1'=>'入驻中','2'=>'暂停中');
	$return['htmls']=$htmls;
	exi($return);
}